﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ThermalEquipmentDesign.Model.SmoothPipeR717R22;
using System.Windows;
using System.Windows.Input;
using ThermalEquipmentDesign.Reference_Path;
using ThermalEquipmentDesign.Reference_Path.Evaporator;


namespace ThermalEquipmentDesign.ViewModel
{
    public class SmoothPiperR717R22ViewModel : ObservableObject
    {
        // Declare fields for binding
        #region fields for binding
        private SmoothPipeR717R22 osmoothpipeR717R22 = new SmoothPipeR717R22();
        private SmoothPipeR717R22Model smoothpipemodel;
        private SmoothPipeR717R22Result osmoothpipeR717R22result = new SmoothPipeR717R22Result();
        private ICommand calculate;
        private String stooltip = "Press F1 for Help";
        #endregion

        // Create properties for binding
        #region properties for binding
        public String sTooltip
        {
            get { return stooltip; }
            set { stooltip = value; }
        }

        public SmoothPipeR717R22 oSmoothPipeR717R22
        {
            get
            {
                return osmoothpipeR717R22;
            }
            set
            {
                if (value != osmoothpipeR717R22)
                {
                    osmoothpipeR717R22 = value;
                    OnPropertyChanged("oSmoothPipeR717R22");
                }
            }
        }
        public SmoothPipeR717R22Model SmoothPipeModel
        {
            get
            {
                return smoothpipemodel;
            }
            set
            {
                if (value != smoothpipemodel)
                {
                    smoothpipemodel = value;
                    OnPropertyChanged("SmoothPipeModel");
                }
            }
        }
        public SmoothPipeR717R22Result oSmoothPipeR717R22Result
        {
            get
            {
                return osmoothpipeR717R22result;
            }
            set
            {
                if (value != osmoothpipeR717R22result)
                {
                    osmoothpipeR717R22result = value;
                    OnPropertyChanged("oSmoothPipeR717R22Result");
                }
            }
        }
        public ICommand Calculate
        {
            get
            {
                if (calculate == null)
                {
                    calculate = new RelayCommand(
                        param => ImplementCalculation()
                    );
                }
                return calculate;
            }
        }
        #endregion

        /// <summary>
        /// Calculate design parameters for Smooth Pipe R717 and R22
        /// </summary>
        public void ImplementCalculation()
        {
            SmoothPipeR717R22Model spm = new SmoothPipeR717R22Model();
            oSmoothPipeR717R22Result = spm.ImplementCalculation(oSmoothPipeR717R22);
        }
        //  Load Reference for the helping 
        public void LoadReference(string sIndex)
        {
            System.Windows.Forms.Help.ShowHelp(null, ReferencePath.ReferenceFile, System.Windows.Forms.HelpNavigator.Index, SmoothPipeR717R22Reference.ResourceManager.GetString(sIndex));
        }
    }
}
